home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 122 / main.c
Encoding:
C/C++ Source or Header  |  1996-08-05  |  2.9 KB  |  97 lines

  1. /*
  2.         A menu prog, I am bored, so, why not put in *MY* bid to take
  3.         the place of MM?  Oooohhhh....  Let's see,
  4.         We want lots of configurability.  Igor!  Bring the config files!
  5. */
  6.  
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include "menu.h"
  10.  
  11. main(int argc, char *argv[])
  12. {
  13.         int i=1;
  14.         /* Engage command-line parser! */
  15.  
  16.         if (argc == 1) {
  17.                 printf("\a\nUuuuhhhhh... Yer supposed to tell me the config file name.");
  18.                 exit(0);
  19.                 }
  20.         /* Okey-dokey, got that down, let's plop up the for loop.*/
  21.         while(0==0)  /* Index=2(i.e. second param, first is: menu.exe)  Up Mr. Index. */
  22.         {
  23.                /* printf("%s", argv[i]);*/
  24.                /* Bug test... */
  25.                /*i=i + 1;*/
  26.                /* We only need the config file name, nothing else. */
  27.                /* Remember, include config file var def in h file. */
  28.                config=fopen(argv[i], "r" );
  29.                if (config == NULL)
  30.                         {
  31.                         /* Uh-oh...  *BIG* problem... */
  32.                         printf("\a\nError: Unable to open config file %s!", argv[i]);
  33.                         printf("\nRead docs for help.");
  34.                         exit(1);
  35.                         }
  36.                /* Now, let us test the error. */
  37.  
  38.                i=loadcnf(config);
  39.                exit(0); /* Exit prog...*/
  40.  
  41.         }
  42.          /*Let's roast this sucker....*/
  43. }
  44.  
  45. atexit()
  46. {
  47.         fclose(config);
  48.         return 0;
  49. }
  50.  
  51. /* Config file data loader. */
  52.  
  53. int loadcnf(FILE *in)
  54. {
  55.         char indata[40];
  56.         int tmp;
  57.         /* Struct defed in menu.h... */
  58.         fscanf(in,"%s", indata);
  59.         if (indata=="ON")
  60.                 {
  61.                 tmp=1;
  62.                 }
  63.                 else
  64.                 {
  65.                 tmp=0;
  66.                 }
  67.         /*Parms.Color = tmp;*/
  68.         /*indata="";*/
  69.         fscanf(in, "%s", indata);
  70.         Parms.EntryOne = indata; /* The beginnings of a long and painful process...*/
  71.         /*indata="";*/
  72.         fscanf(in, "%s", indata);
  73.         Parms.EntryOnePath = indata;
  74.         fscanf(in, "%s", indata);
  75.         Parms.EntryTwo = indata;
  76.         fscanf(in, "%s", indata);
  77.         Parms.EntryTwoPath = indata;
  78.         fscanf(in, "%s", indata);
  79.         Parms.EntryThree = indata;
  80.         fscanf(in, "%s", indata);
  81.         Parms.EntryThreePath = indata;
  82.         fscanf(in, "%s", indata);
  83.         Parms.EntryFour = indata;
  84.         fscanf(in, "%s", indata);
  85.         Parms.EntryFourPath = indata;
  86.         fscanf(in, "%s", indata);
  87.         Parms.EntryFive = indata;
  88.         fscanf(in, "%s", indata);
  89.         Parms.EntryFivePath = indata;
  90.         fscanf(in, "%s", indata);
  91.         Parms.EntrySix = indata;
  92.         fscanf(in, "%s", indata);
  93.         Parms.EntrySixPath = indata;
  94.         /* YESSSSSSS!!!!!  I am *DONE* setting up the config reader!!!*/
  95.         return 0;
  96. }
  97.